import Base from './Base'
import Page from './Page'

class Announce extends Base {
  constructor ({
    id = '',
    title = '',
    coverImage = '',
    text = '',
    audio = '',
    attachment = '',
    sendStatus = '',
    sort = '',
    readCount = '',
    sendCount = '',
    likeCount = '',
    commentCount = '',
    time = '',
    userNames = [],
    linkeStatus = '',
    readStatus = '',
    createUser = ''
  }) {
    super({id})

    this.title = title
    this.coverImage = coverImage
    this.text = text
    this.audio = audio
    this.attachment = attachment
    this.sendStatus = sendStatus
    this.sort = sort
    this.readCount = readCount
    this.sendCount = sendCount
    this.likeCount = likeCount
    this.commentCount = commentCount
    this.time = time
    this.userNames = userNames
    this.linkeStatus = linkeStatus
    this.readStatus = readStatus
    this.createUser = createUser
  }
  // 公告草稿列表 - PC
  static async findDraftList (params) {
    let {content, ...pagination} = await Announce.$http.get(`${Announce.$name}/draft/list`, {params})
    content = content.map(v => new this(v))
    pagination = new Page(pagination)
    return {content, pagination}
  }
  // 公告列表 - MT
  static async findMtList (params) {
    let {content, ...pagination} = await Announce.$http.get(`${Announce.$name}/wechat/list`, {params})
    content = content.map(v => new this(v))
    pagination = new Page(pagination)
    return {content, pagination}
  }
  // 公告详情 - MT
  static async findMtOne (params) {
    let res = await Announce.$http.get(`${Announce.$name}/wechat/detail`, {params})
    return new this(res)
  }
}
// 静态属性
Announce.$name = '/announce'
export default Announce
